package com.example.netty.inoutbound.review2;

import io.netty.channel.ChannelHandlerContext;
import io.netty.channel.SimpleChannelInboundHandler;

public class MyClientHandler extends SimpleChannelInboundHandler {
    @Override
    protected void channelRead0(ChannelHandlerContext ctx, Object msg) throws Exception {
        System.out.println("服务器的ip="+ ctx.channel().remoteAddress() +";读取到客户端返回的数据" + msg);
    }

    // 重写 channelActive 发送数据
    @Override
    public void channelActive(ChannelHandlerContext ctx) throws Exception {
        System.out.println("MyClientHandler 发送数据");
        // 下面这行代码会走 MyLongToByteEncoder
        ctx.writeAndFlush(123456L); // 发送一个 long
        ctx.writeAndFlush(654326L); // 发送一个 long
    }
}
